import { create } from 'zustand'

interface LanguageState {
  language: string
  changeLanguage: (by: string) => void
}

const useLanguageStore = create<LanguageState>((set) => ({
    language: localStorage.getItem('language') || 'cn',
    changeLanguage: (by) => set(() => { 
        localStorage.setItem('language', by)
        return {
            language: by
        }
    }),
}))

export {
    useLanguageStore
}